package com.github.szhittech.service.task.impl;


import com.github.szhittech.service.api.ApiService;
import com.github.szhittech.service.api.inter.IProjectExecute;
import com.github.szhittech.util.Logc;

import org.gradle.api.Action;
import org.gradle.api.DefaultTask;
import org.gradle.api.Project;
import org.gradle.api.internal.tasks.userinput.UserInputHandler;
import org.gradle.api.tasks.TaskAction;

import java.io.IOException;

public class TestTask extends DefaultTask {
    @TaskAction
    public void update() throws IOException {
        Logc.e("======TestTask==update=>");

        UserInputHandler handler = this.getServices().get(UserInputHandler.class);
        String respose = handler.askQuestion("AAAAAAAAAA","BBBBBBBBBBBBBB");
        Logc.e("====>"+respose);
        Boolean y = handler.askYesNoQuestion("Y/N...");
        Logc.e("====>"+y);

        getProject().afterEvaluate(new Action<Project>() {
            @Override
            public void execute(Project project) {
                IProjectExecute projectExecute = ApiService.getInstance(IProjectExecute.class);
                if (projectExecute != null) {
                    projectExecute.execute(project);
                }
            }
        });

    }
}
